using UnityEngine;

namespace NJG
{
	public class UIMapArrow : MonoBehaviour
	{
		[SerializeField]
		public NJGMapItem item;

		public Transform child;

		public bool isValid;

		[HideInInspector]
		public UISprite sprite;

		private Transform mTrans;

		public Transform cachedTransform
		{
			get
			{
				if (mTrans == null)
				{
					mTrans = base.transform;
				}
				return mTrans;
			}
		}

		public void UpdatePosition(Vector2 mapPos, Vector2 mapHalfScale, float SinA, float cosA)
		{
			float value = mapPos.x * cosA - mapPos.y * SinA;
			float value2 = mapPos.y * cosA + mapPos.x * SinA;
			cachedTransform.localPosition = new Vector3(Mathf.Clamp(value, (float)sprite.width / 2f - mapHalfScale.x + 2f, mapHalfScale.x - (float)sprite.width / 2f - 2f), Mathf.Clamp(value2, (float)sprite.height / 2f - mapHalfScale.y + 2f, mapHalfScale.y - (float)sprite.height / 2f - 2f), 0f);
		}
	}
}
